home *** CD-ROM | disk | FTP | other *** search
/ Computer Shopper 233 / Computer Shopper 233 / ComputerShopperDVD233.iso / mpf / eng / shared / agentdui.cab / scui.dll / HTML / COMMON.VBS < prev    next >
Encoding:
Text File  |  2005-07-27  |  9.6 KB  |  416 lines

  1. Function window_onerror( sMsg, sUrl, nLine )
  2. '{
  3.     MsgBox DB_FATAL_ERROR & vbCrLf & vbCrLf & "Msg: " & sMsg & vbCrLf & "Url:" & sUrl & vbCrLf & "Line No:" & CStr(nLine)
  4.     'window.external.close
  5.     window.event.returnValue = TRUE '// Dont display IE message.
  6. '}
  7. End Function
  8.  
  9. Function GetInternetConnectedState()
  10. '{
  11.     If top.gObjDashboard is nothing Or not IsObject( top.gObjDashboard ) Then
  12.         Exit Function
  13.     End If
  14.  
  15.     Dim bINetConnected
  16.     Dim bInetState
  17.  
  18.     bINetConnected = top.gObjDashboard.GetInternetConnectedState( bInetState )
  19.  
  20.     GetInternetConnectedState = bINetConnected
  21. '}
  22. End Function
  23.  
  24. Function LaunchURL( szUrlToLaunch )
  25. '{
  26.     If top.gObjDashboard is nothing Or not IsObject( top.gObjDashboard ) Then
  27.         Exit Function
  28.     End If
  29.  
  30.     Dim bINetConnected
  31.     Dim bInetState
  32.  
  33.     bINetConnected = top.gObjDashboard.GetInternetConnectedState( bInetState )
  34.     If bINetConnected Then
  35.         If "" <> szUrlToLaunch Then
  36.             window.open szUrlToLaunch, "McDash"
  37.         End If
  38.     Else
  39.         MsgBox DB_INET_NOT_CONNECTED_ERROR
  40.     End If 
  41.  
  42.     LaunchURL = TRUE
  43. '}
  44. End Function
  45.  
  46. Function LaunchURLInWindow( szUrl, szTarget, szWindowParams )
  47. '{
  48.     If top.gObjDashboard is nothing Or not IsObject( top.gObjDashboard ) Then
  49.         Exit Function
  50.     End If
  51.  
  52.     Dim bINetConnected
  53.     Dim bInetState
  54.  
  55.     bINetConnected = top.gObjDashboard.GetInternetConnectedState( bInetState )
  56.  
  57.     If bINetConnected Then
  58.         If "" <> szUrl Then
  59.             window.open szUrl, szTarget, szWindowParams
  60.         End If
  61.     Else
  62.         MsgBox DB_INET_NOT_CONNECTED_ERROR
  63.     End If 
  64.  
  65.     LaunchURLInWindow = TRUE
  66. '}
  67. End Function
  68.  
  69. Function LaunchURLOrExe( szURL )
  70. '{
  71.     Dim bInetState, szFile
  72.     'On Error Resume Next
  73.     If g_localObjOS Is Nothing Or Not IsObject( g_localObjOS ) Then
  74.         Exit Function
  75.     End If
  76.     If g_localObjFS Is Nothing Or Not IsObject( g_localObjFS ) Then
  77.         Exit Function
  78.     End If
  79.  
  80.     If (IsProgram(szURL)) Then
  81.         szFile = Mid(szURL, 8)
  82.         If (":\" <> Mid(szFile, 2, 2)) Then
  83.             szFile = GetObjectPath( CLSID_MCAgent, g_localObjOS, g_localObjFS ) & "\" & szFile
  84.         End If
  85.         If 0 <> g_localObjOS.RunProgram(szFile, "") Then
  86.             MsgBox DB_PROGRAM_LAUNCH_ERROR
  87.         End If
  88.     Else
  89.         LaunchURL(szUrl)
  90.     End If
  91.     window.event.returnValue = FALSE
  92.     'On Error Goto 0
  93. '}
  94. End Function
  95.  
  96.  
  97. Function ShellExecuteURL( szURL, ByRef g_localObjOS, ByRef g_localObjFS, ByRef g_localObjShell )
  98. '{
  99.  
  100.     Dim bInetState
  101.     'On Error Resume Next
  102.  
  103.     If g_localObjOS Is Nothing Or Not IsObject( g_localObjOS ) Then
  104.         Exit Function
  105.     End If
  106.  
  107.     If g_localObjFS Is Nothing Or Not IsObject( g_localObjFS ) Then
  108.         Exit Function
  109.     End If
  110.  
  111.     If g_localObjShell Is Nothing Or Not IsObject( g_localObjShell ) Then
  112.         Exit Function
  113.     End If
  114.  
  115.     If ( Not IsHttp(szURL) ) Then
  116.         If 0 <> g_localObjShell.ShellExecute(szURL) Then
  117.             MsgBox DB_PROGRAM_LAUNCH_ERROR
  118.         End If
  119.     Else
  120.         Call LaunchURL(szUrl)
  121.     End If
  122.  
  123.     window.event.returnValue = FALSE
  124.     'On Error Goto 0
  125. '}
  126. End Function
  127.  
  128.  
  129. Function IsProgram(szURL)
  130. '{
  131.     IsProgram = FALSE
  132.     '// file://a.exe
  133.     If (11 < Len(szURL)) Then
  134.         If ( (0 =  StrComp("file://", Left(szURL, 7), 1)) And _
  135.              (0 <> StrComp(".htm",  Right(szURL, 4), 1))  And _
  136.              (0 <> StrComp(".html", Right(szURL, 5), 1)) ) Then            
  137.             IsProgram = TRUE
  138.  
  139.         End If
  140.  
  141.     End If
  142. '}
  143. End Function
  144.  
  145.  
  146. Function IsHttp(szUrl)
  147. '{
  148.  
  149.     If (0 =  StrComp("http://", Left(szUrl, 7), 1) ) Then
  150.         IsHttp = True
  151.     Else
  152.         IsHttp = False
  153.     End If
  154.  
  155. '}
  156. End Function
  157.  
  158. Function GetObjectPath( sCLSID, objOS, objFS )
  159. '{
  160.     Dim   sPath
  161.  
  162.     GetObjectPath = ""
  163.     sPath = objOS.GetObjectModuleDir( sCLSID )
  164.     If "" = sPath Then
  165.     '{
  166.         Exit Function
  167.     '}
  168.     End If
  169.  
  170.     GetObjectPath = objFS.GetShortPathName( sPath )
  171. '}
  172. End Function
  173.  
  174. Function LaunchHelp( sUrl, objOS )
  175. '{
  176.   Dim sHHPath, sHelpUrl
  177.  
  178.   window.event.cancelBubble = True
  179.  
  180.   '// Check if required objects are present...
  181.   If False = IsObject( objOS ) Then
  182.     Exit Function
  183.   End If
  184.  
  185.   If objOS is nothing Then
  186.     Exit Function
  187.   End If
  188.  
  189.   '// Get HH.EXE path...
  190.   sHHPath = objOS.WindowsDirectory
  191.   If "\" <> Right( sHHPath, 1 ) Then
  192.     sHHPath = sHHPath & "\"
  193.   End If
  194.   sHHPath = sHHPath & "hh.exe"
  195.  
  196.   If "" <> sUrl Then
  197.       '// Start the Help
  198.       call objOS.RunProgram( sHHPath, sUrl )
  199.   End If
  200.  
  201. '}
  202. End Function
  203.  
  204.  
  205. Function GetAppSecurityIndex( szAppId )
  206. '{
  207.     GetAppSecurityIndex = 0
  208.  
  209.     Dim localObjMcScIndx
  210.     Const SECIDX_SUCCESS = 0
  211.  
  212.     Dim nSecIdx
  213.     nSecIdx = 0
  214.  
  215.     Set localObjMcScIndx = Nothing
  216.  
  217.     If IsEmpty (top.gobjExternal.GetParam("MYS_SEC_IDX")) Then
  218.         Set localObjMcScIndx = top.gobjExternal.CreateObject( CLSID_CoMCSecurityIndex, CLSID_LIC, true )
  219.         'Call top.gobjExternal.SetParam("MYS_SEC_IDX", localObjMcScIndx)
  220.     Else
  221.         Set localObjMcScIndx = top.gobjExternal.GetParam("MYS_SEC_IDX")
  222.     End If
  223.  
  224.     If Not localObjMcScIndx is Nothing And IsObject( localObjMcScIndx ) Then
  225.         If ( SECIDX_SUCCESS <> localObjMcScIndx.GetAppSecurityIndex(szAppId, nSecIdx) ) Then
  226.             nSecIdx = -1
  227.         End If 
  228.     End If
  229.  
  230.     Set localObjMcScIndx = Nothing
  231.  
  232.     GetAppSecurityIndex = nSecIdx
  233. '}
  234. End Function
  235.  
  236. Function GetTitleStateSpecs( state, ByRef backgroundColor, ByRef borderColor, ByRef ltCornerImg, ByRef lbCornerImg, ByRef rtCornerImg, ByRef rbCornerImg, ByRef streetLight )
  237. '{
  238.     Select Case state
  239.     '{
  240.         case DB_NO_PROD_INSTALLED
  241.             backgroundColor = DB_NOTINSTALLED_BGCLR_STR
  242.             borderColor = DB_NOTINSTALLED_BORDERCLR_STR
  243.             ltCornerImg = DB_NOTINSTALLED_LTIMG_STR
  244.             lbCornerImg = DB_NOTINSTALLED_LBIMG_STR
  245.             rtCornerImg = DB_NOTINSTALLED_RTIMG_STR
  246.             rbCornerImg = DB_NOTINSTALLED_RBIMG_STR
  247.             streetLight = DB_NOT_INSTALLED_STRTLT_STR
  248.         case DB_PROD_ENABLED
  249.             backgroundColor = DB_ENABLED_BGCLR_STR
  250.             borderColor = DB_ENABLED_BORDERCLR_STR
  251.             ltCornerImg = DB_ENABLED_LTIMG_STR
  252.             lbCornerImg = DB_ENABLED_LBIMG_STR
  253.             rtCornerImg = DB_ENABLED_RTIMG_STR
  254.             rbCornerImg = DB_ENABLED_RBIMG_STR
  255.             streetLight = DB_ENABLED_STRTLT_STR
  256.         case DB_PROD_DISABLED
  257.             backgroundColor = DB_DISABLED_BGCLR_STR
  258.             borderColor = DB_DISABLED_BORDERCLR_STR
  259.             ltCornerImg = DB_DISABLED_LTIMG_STR
  260.             lbCornerImg = DB_DISABLED_LBIMG_STR
  261.             rtCornerImg = DB_DISABLED_RTIMG_STR
  262.             rbCornerImg = DB_DISABLED_RBIMG_STR
  263.             streetLight = DB_DISABLED_STRTLT_STR
  264.     '}
  265.     End Select
  266. '}
  267. End Function
  268.  
  269. ' NOTE: Caller should only add one to return value for MPF3.0
  270. ' Returns # days remaining until service expires.
  271. ' -2 = Doesn't expire or error (no expiry entry found) 
  272. ' -1 = Expired sometime in past
  273. ' 1+ = Days remaining until trial service expires.
  274. Function GetExpiryDays(objLegacySubMgr, szAppId)
  275. '{
  276.     Dim lRetVal
  277.  
  278.     If objLegacySubMgr is nothing Or Not IsObject( objLegacySubMgr ) Then
  279.         GetExpiryDays = dwDays
  280.         Exit Function
  281.     End If
  282.         
  283.     GetExpiryDays = objLegacySubMgr.GetExpiryDays(szAppId, lRetVal)
  284. '}
  285. End Function
  286.  
  287.  
  288. ' Follows this algorithm...
  289. ' 1. If No Die is set then returns 0
  290. ' 2. Calls IsAppExpired... If it returns -1 (unknwown expiry) or Result <> 7000 (SUCCESS)
  291. '    then checks if bPerpetual = True. Returns 2 (PERPETUAL & EXPIRED) if Perpetual otherwise returns 1
  292. '    which means SUBSCRIPTION & EXPIRED.
  293.  
  294. ' IsAppExpired returns the following values...
  295. ' 0 = NOT_EXPIRED
  296. ' 1 = SUBSCRIPTION_EXPIRED
  297. ' 2 = PERPETUAL_EXPIRED
  298. ' 4 = TRIAL_EXPIRED
  299. ' 8 = NO_DIE_EXPIRED
  300. ' -1 = EXPIRY_UNKNWON (because of some error...)
  301.  
  302. Function IsAppExpired(ByVal szAppId, ByRef objLegacySubMgr)
  303. '{
  304.  
  305.     Dim lRetVal
  306.     Dim bNoDie, bPerpetual, bTrial
  307.  
  308.     bNoDie      = False
  309.     bPerpetual  = False
  310.     bTrial      = False
  311.  
  312.     ' 7000 = SUCCESS as defined MCSUBDEF.H
  313.     ' 7020 = MCSUBOBJRET_INVALID_APPSUBINFO. We will get this if Settings is not found in registry or
  314.     ' in the case of sub aware apps we dont find it in the database.
  315.  
  316.     lRetVal = 7000
  317.     
  318.     If ( Len(szAppId) = 0 ) Or ( Not IsObject(objLegacySubMgr) ) Then
  319.     '{
  320.         IsAppExpired = 0
  321.         Exit Function
  322.     '}
  323.     End If
  324.  
  325.     ' first check if this is NO_DIE
  326.     bNoDie = objLegacySubMgr.IsNoDie(szAppId, lRetVal)
  327.     If 7000 <> lRetVal Then
  328.         bNoDie = False
  329.     End If
  330.  
  331.     If bNoDie Then
  332.     '{
  333.         IsAppExpired = 0
  334.         Exit Function
  335.     '}
  336.     End If
  337.  
  338.     lRetVal = 7000
  339.  
  340.     bTrial = objLegacySubMgr.IsTrial(szAppId, lRetVal)
  341.     If 7000 <> lRetVal Then
  342.         bTrial = False
  343.     End If
  344.  
  345.     lRetVal = 7000
  346.  
  347.     If Not bTrial Then
  348.     '{
  349.  
  350.         bPerpetual = objLegacySubMgr.IsPerpetual(szAppId, lRetVal)
  351.         If 7000 <> lRetVal Then
  352.             bPerpetual = False
  353.         End If
  354.  
  355.     '}
  356.     End If
  357.  
  358.     lRetVal = 7000
  359.  
  360.     IsAppExpired = objLegacySubMgr.IsAppExpired(szAppId, lRetVal)
  361.  
  362.     If (7000 <> lRetVal) Or (-1 = IsAppExpired) Then
  363.     '{
  364.         If bPerpetual Then
  365.             IsAppExpired = 2
  366.         Else
  367.             IsAppExpired = 1
  368.         End If
  369.     '}
  370.     Else
  371.     '{
  372.         ' 4 = Trial Expired... Treat it the same way as a normal subscription has expired...
  373.  
  374.         If 4 = IsAppExpired Then
  375.             IsAppExpired = 1
  376.         End If
  377.     '}
  378.     End If
  379.  
  380. '}
  381. End Function
  382.  
  383. Function GetRunningFlag(ByVal nExpiry)
  384. '{
  385.  
  386.     Dim isRunningFlag
  387.  
  388.     ' default is protecting...
  389.     ' This function will be called ONLY when nExpiry > 0
  390.     isRunningFlag = 1
  391.  
  392.     If (nExpiry > 0) Then
  393.     '{
  394.  
  395.         ' Trial expired or paid subscription expired...
  396.  
  397.         If (1 = nExpiry) Or (4 = nExpiry) Then
  398.         '{
  399.             ' Subscription is expired...
  400.             isRunningFlag = 100
  401.         '}
  402.         Else
  403.         '{
  404.             ' Perpetual is true and perpetual subscription expired... Or 
  405.             isRunningFlag = 101
  406.         '}
  407.         End If
  408.  
  409.     '}
  410.     End If
  411.  
  412.     GetRunningFlag = isRunningFlag
  413.  
  414. '}
  415. End Function
  416.